﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Wpf_Tool_ZC.util
{
    class UtilFile
    {

        public static List<string> ReadTxt(string path)
        {
            List<string> list = new List<string>();
            StreamReader sr = new StreamReader(path, Encoding.Default);
            String line;
            while ((line = sr.ReadLine()) != null)
            {
                //Console.WriteLine(line.ToString());
                list.Add(line);
            }

            return list;
        }

        public void WriteTxt(string _path, List<string> _list)
        {
            FileStream fs = new FileStream(_path, FileMode.CreateNew);
            StreamWriter sw = new StreamWriter(fs);
            //开始写入
            for (int i = 0; i < _list.Count; i++)
                sw.Write(_list[i]);
            //清空缓冲区
            sw.Flush();
            //关闭流
            sw.Close();
            fs.Close();
        }


    }
}
